package day20160803;
import net.sf.json.*;
import java.util.List;
import java.util.Map;

public class TestJson {
	public static Map getObject(String s){
		return JSONObject.fromObject(s);
		//从json格式的字符串转换为Map对象
	}
	public static List getArray(String s){
		return JSONArray.fromObject(s);
		//从json格式的字符串转换为List数组
	}
	public static Object getObject(String s,Class cls){
		JSONObject jo=JSONObject.fromObject(s);
		return JSONObject.toBean(jo, cls);
		//从json格式的字符串转换为某个Bean
	}
	public static Object getArray(String s,Class cls){
		JSONArray ja=JSONArray.fromObject(s);
		return JSONArray.toArray(ja, cls);
		//从json格式的字符串转换为某类对象的数组
	}
}
